package com.hxzy.research.controller.front;

import com.hxzy.research.form.CareerForm;
import com.hxzy.research.pojo.TblCareerResearch;
import com.hxzy.research.service.pageandmanager.AddFrontCareer;
import com.hxzy.research.util.ListSumUtil;
import com.hxzy.research.vo.ResultVo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping(value = "/front")
public class AddFrontCareerController {
    @Autowired private AddFrontCareer addFrontCareer;
    @RequestMapping("/addCareerResearch.go")
    public @ResponseBody
    ResultVo addCareerResearch(CareerForm careerForm, HttpSession session)throws Exception{
        Integer branchId=(Integer) session.getAttribute("branchId");
        TblCareerResearch tblCareerResearch=new TblCareerResearch();
        tblCareerResearch.setBranchId(branchId);
        tblCareerResearch.setClassId(careerForm.getClassId());
        tblCareerResearch.setZyyb(ListSumUtil.getSum(careerForm.getZyyb()));
        tblCareerResearch.setJxtd(ListSumUtil.getSum(careerForm.getJxtd()));
        tblCareerResearch.setJxxg(ListSumUtil.getSum(careerForm.getJxxg()));
        tblCareerResearch.setJy(careerForm.getJy());
        tblCareerResearch.setTjDate(new Date());
        addFrontCareer.AddCareerResearch(tblCareerResearch);
        ResultVo resultVo=new ResultVo("200","提交成功");
        return resultVo;
    }
}
